package com.xhj.xmly.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xhj.xmly.R;
import com.xhj.xmly.adapter.DiscoverAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by XHJ on 2016/12/2.
 */
public class DiscoverFragment extends Fragment {
    private ViewPager viewPager;
    private Discoer_list_frag discoer_list_frag;
    private Discover_broadcast_frag discover_broadcast_frag;
    private Discover_classify_frag discover_classify_frag;
    private Discover_hoster_frag discover_hoster_frag;
    private Discover_recommend_frag discover_recommend_frag;

    private List<Fragment> list;
    private String[] titles={"推荐","分类","广播","榜单","主播"};
    private DiscoverAdapter discoverAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.discover_fragment,container,false);
        viewPager = ((ViewPager) view.findViewById(R.id.discover_viewPager));

        discoer_list_frag = new Discoer_list_frag();
        discover_broadcast_frag = new Discover_broadcast_frag();
        discover_classify_frag = new Discover_classify_frag();
        discover_hoster_frag = new Discover_hoster_frag();
        discover_recommend_frag = new Discover_recommend_frag();
        list = new ArrayList<>();
        list.add(discover_recommend_frag);
        list.add(discover_classify_frag);
        list.add(discover_broadcast_frag);
        list.add(discoer_list_frag);
        list.add(discover_hoster_frag);
        discoverAdapter = new DiscoverAdapter(getFragmentManager(),list,getContext(),titles);
        viewPager.setAdapter(discoverAdapter);
        return view;

    }
}
